<template>
  <view class="container">
    <uv-navbar
      title="我的优惠劵"
      bg-color="none"
      @leftClick="leftClick"
    ></uv-navbar>
    <view class="coupon-box" v-if="false">
      <view class="tab">
        <view class="tab-list">
          <view
            class="tab-item"
            :class="{ active: index == tab.active }"
            v-for="(item, index) in tab.list"
            :key="item.value"
            @click="ckTab(index)"
            >{{ item.title }}</view
          >
        </view>
      </view>
    </view>
    <view class="list">
      <view class="list-item" v-for="(item, index) in dataLits" :key="item.id">
        <view class="left-image" style="width: 25%">
          <span style="font-size: 32rpx">¥</span>
          <span style="font-size: 49rpx; margin-left: 12rpx">{{
            item.reduceMoney || item.discountMoney
          }}</span>
        </view>
        <view class="right" v-if="item.couponType == 1" style="width: 50%">
          <view class="title"
            >满{{ item.satisfyMoney }}减{{ item.reduceMoney }}</view
          >
          <view class="date">领取后{{ item.validDays }}天有效</view>
          <view class="date">使用范围：不限</view>
        </view>
        <view class="right" v-else style="width: 50%">
          <view class="title">无门槛劵</view>
          <view class="date">领取后{{ item.validDays }}有效</view>
          <view class="date">使用范围：不限</view>
        </view>
        <view style="width: 35%"></view>
        <!-- <view class="dy-iconfont icon-yishiyong1"></view>
        <view class="dy-iconfont icon-yiguoqi"></view> -->
      </view>
    </view>
    <uv-empty
      v-if="dataLits.length <= 0"
      mode="message"
      text="暂无优惠劵"
      textColor="#000"
      icon="http://jy-nfc.oss-cn-hangzhou.aliyuncs.com/2025/01/24/cf3aa70933d942a7a7a71ea378bb4c50.png"
    ></uv-empty>
  </view>
</template>

<script>
const app = getApp();
import { getMyCouponList } from "@/common/api";
export default {
  data() {
    return {
      tab: {
        active: 0,
        list: [
          {
            title: "全部",
            value: 0,
          },
          {
            title: "待使用",
            value: 1,
          },
          {
            title: "已使用",
            value: 2,
          },
          {
            title: "已过期",
            value: 3,
          },
        ],
      },
      dataLits: [],
    };
  },
  onShow() {
    this.getData();
  },
  methods: {
    leftClick() {
      app.navigateBack();
    },
    ckTab(index) {
      if (this.tab.active != index) {
        this.tab.active = index;
      }
    },
    getData() {
      getMyCouponList(this.$store.state.user.userId).then((res) => {
        this.dataLits = res.data;
        console.log(res);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  overflow: hidden;
  min-height: 100vh;
  width: 100vw;
  padding: 40rpx;
  padding-top: 226rpx;
  // padding-bottom: calc(96rpx + 32rpx + 22rpx);
  box-sizing: border-box;
  background: #f7f8fa;
  background: radial-gradient(
    128% 128% at 95% 0%,
    #d7ceff 0%,
    #bbe1ff 62%,
    #ffffff 95%
  );

  .tab {
    .tab-list {
      height: 120rpx;
      background: rgba(255, 255, 255, 0.3);
      border-radius: 32rpx 32rpx 32rpx 32rpx;
      border: 2rpx solid #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 20rpx;
      box-sizing: border-box;

      .tab-item {
        width: 306rpx;
        height: 80rpx;
        line-height: 80rpx;
        border-radius: 16rpx;
        font-weight: 500;
        font-size: 30rpx;
        color: #000000;
        text-align: center;

        &.active {
          background: linear-gradient(180deg, #886ae6 0%, #4635ff 99%);
          color: #ffffff;
        }
      }
    }
  }
  .list {
    // padding: 32rpx 24rpx;
    // box-sizing: border-box;
    margin-top: 24rpx;

    .list-item {
      padding: 24rpx 40rpx;
      box-sizing: border-box;
      border-radius: 20rpx;
      background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.62) 64%,
        #ffffff 100%
      );
      box-shadow: 0rpx 0rpx 40rpx 0rpx rgba(0, 0, 0, 0.04);
      border: 2rpx solid #ffffff;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 24rpx;
      .dy-iconfont {
        font-size: 120rpx;
      }

      .left-image {
        border-radius: 12rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ff4e04;
        font-weight: 900;
      }

      .right {
        .title {
          font-weight: 700;
          font-size: 36rpx;
          color: #000000;
          line-height: 36rpx;
          margin-bottom: 16rpx;
        }

        .date {
          font-weight: 400;
          font-size: 28rpx;
          color: #86909c;
          line-height: 40rpx;
        }
      }
    }
  }
}
</style>
